package cn.cscb.mms.server.aspect;

import cn.cscb.mms.common.context.BaseContext;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class ThreadLocalCleanupAspect {

    @After("execution(* cn.cscb.mms.server.controller..*.*(..))")
    public void cleanupThreadLocal() {
        String empNo = BaseContext.getCurrentEmpNo();
        if(empNo != null) {
            log.info("清除BaseContext.ThreadLocal的值：{}",BaseContext.getCurrentEmpNo());
            BaseContext.removeCurrentEmpNo();
        }
    }
}
